
<div class="company_option shop_bg{{$shop['sp_templete']}}">
    <div class="w1200">
        <ul>
            <a href="/shop/index/{{$shop['sp_id']}}" ><li data-type="supply_index"  class="index ">首页</li></a>
            <a href="/shop/products/{{$shop['sp_id']}}"><li data-type="supply_glists" class="products ">供应产品</li></a>
            <a href="/shop/archives/{{$shop['sp_cmp_id']}}"><li data-type="archives" class="archives ">公司档案</li></a>
            <a href="/shop/attribute/{{$shop['sp_id']}}"><li data-type="attribute" class="attribute ">资质服务</li></a>

        </ul>
        @if(array_get($check,'checkShop')&&session('user_id')!=null)
        <div class="on_collection">已收藏店铺</div>
        @else
        <div class="on_collection collection_shop">收藏店铺</div>
        @endif
    </div>
</div>
<script>
    $(function () {
        //用户中心侧边栏焦点固定
        var url = window.location.pathname;
        var arr_url = url.split("/")[2];
        console.log(arr_url);
        $('.company_option li.'+arr_url).addClass('active');// 新增选中，避免二级页面选中失败

        var jud = '{{ Session::get("user_id")}}';
        //收藏店铺
        $(document).on("click",".collection_shop",function () {
            if (jud == '' || jud == '0') {
                layer.confirm('请先登录后再关注店铺，点击【确认】跳转到登录页面', {
                    title: '温馨提示',
                    btn: ['确认', '取消'] //可以无限个按钮
                }, function (index) {
                    window.location.href = AJAX_URL + '/user/login';
                }, function (index) {
                    layer.close(index);
                });
                return false;

            } else {
                var shop_id = '{{$shop['sp_id']}}';
//                    var pid = 9378;
                var token = '{{csrf_token()}}';
                $.ajax({
                    url: '/product/collection',
                    type: 'GET',
                    dataType: 'json',
                    data: { _token: token,type:'shop','shop_id':shop_id},
                    success: function (data) {
                        if (data.code == 0) {
                            $('.collection_shop').html('已收藏店铺');
                            layer.alert('店铺收藏成功');
                        }else{
                            layer.alert('店铺收藏失败');
                        }
                    }

                })
            }
        });
    })
</script>